<template>
  <div class="head-container">
    <div class="wrap-container">
      <div class="logo-container" @click="goPage('Index_page')">
        <img :src="enterpriseInfo.logo" alt="logo"/>
        <div class="text">
          <span class="cn">{{enterpriseInfo.abbreviation}}</span>
          <span class="en">{{enterpriseInfo.enName}}</span>
        </div>
      </div>
      <div class="btn-container">
        <div :class="{'btn':true, 'btn-active':item.name == currentRouteName} " v-for="item in btnOptions" :key="item.title" @click="goPage(item.name)">
          {{ item.title }}
          <span class="underline"></span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import {reactive, ref} from "vue";
import {useRouter} from 'vue-router'
import {pageOptions} from '@/utils/data';
import {enterprise} from "@/utils/data";

const router = useRouter();
const currentRouteName = ref('Index_page');

// 数据获取
const enterpriseInfo = enterprise;
const btnOptions = pageOptions;

const data = reactive({})

// 跳转页面
const goPage = (name) => {
  router.push(name);
  currentRouteName.value = name;
}

</script>

<style lang="scss" scoped>
.head-container {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: $headerHeight;
  @include frostedGlass();
  user-select: none;
  @include flex($row: center);
  z-index: 1;
  box-shadow: 0 0 6px 3px rgba(0, 0, 0, .1);

  .wrap-container {
    width: $maxWidth;
    height: 100%;
    margin: 0 auto;
    @include flex($col: center, $row: space-between);

    .logo-container {
      //width: 200px;
      height: 100%;
      margin-right: 20px;
      cursor: pointer;
      @include flex($col: center);

      img {
        height: 65%;
      }

      .text {
        margin-left: 10px;
        color: #2b2e2e;
        @include flex($row: center, $direc: column);
        font-weight: bold;
        font-size: 12px;

        .cn {
          letter-spacing: 5px;
        }

        .en {
        }
      }
    }

    .btn-container {
      flex: 1;
      height: 100%;
      @include flex();

      .btn {
        flex: 1;
        height: 100%;
        font-size: 15px;
        @include flex($row:center, $col:center);
        cursor: pointer;
        color: #2b2e2e;
        position: relative;
        .underline{
          position: absolute;
          bottom: 0px;
          //left: 50%;
          width: 0;
          height: 4px;
          background-color: #ffffff;
          //transform: translateX(-50%);
          @include transition();
        }
      }
      .btn-active{
        color: $themeColor;
        font-weight: bold;
        .underline{
          width: 70%;
          background-color: $themeColor;
        }
      }
      .btn:hover {
        font-weight: bold;
        .underline{
        }
      }
    }
  }
}

</style>
